package com.gdb.view;

import java.util.Collection;

import com.gdb.controller.GuitarControl;
import com.gdb.model.Guitar;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class GuitarAction extends ActionSupport {
	
	private Guitar guitar;
	private Collection<Guitar> guitars;
	private Long id;
	
	private GuitarControl guitarControl;
	
	public GuitarAction() {
		this.guitarControl = new GuitarControl();
	}
	
	public String execute() {
		this.guitars = guitarControl.list();
		return SUCCESS;
	}
	
	public String add() {
		try {
			guitarControl.add(getGuitar());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		guitarControl.list();
		
		return SUCCESS;
	}
	
	public String delete() {
		guitarControl.delete(getId());
		return SUCCESS;
	}
	
	public Guitar getGuitar() {
		return guitar;
	}
	public Collection<Guitar> getGuitars() {
		return guitars;
	}
	public Long getId() {
		return id;
	}
	public void setGuitar(Guitar guitar) {
		this.guitar = guitar;
	}
	public void setGuitars(Collection<Guitar> guitars) {
		this.guitars = guitars;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
}
